<?PHP
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: selfpickup.php 135 2013-09-22 07:30:55Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 135 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:30:55 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright © since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	© 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	© 2002-2003 osCommerce - www.oscommerce.com
* 	© 2003     nextcommerce - www.nextcommerce.org
* 	© 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

class selfpickup {
    var $code, $title, $description, $icon, $enabled, $db;

    function __construct() {
    	global $db;
        $this->code        = 'selfpickup';
        $this->title       = MODULE_SHIPPING_SELFPICKUP_TEXT_TITLE;
        $this->description = MODULE_SHIPPING_SELFPICKUP_TEXT_DESCRIPTION;
        $this->icon        = '';   // change $this->icon =  DIR_WS_ICONS.'shipping_ups.gif'; to some freeshipping icon
        $this->sort_order  = MODULE_SHIPPING_SELFPICKUP_SORT_ORDER;
        $this->enabled = ((MODULE_SHIPPING_SELFPICKUP_STATUS == 'True') ? true : false);
        $this->db = $db;
    }

    function quote($method = '') {
        $this->quotes = array('id' => $this->code,
            					'module' => MODULE_SHIPPING_SELFPICKUP_TEXT_TITLE);

	    $this->quotes['methods'] = array(array('id' => $this->code,
										        'title' => MODULE_SHIPPING_SELFPICKUP_TEXT_WAY,
										        'cost'  => 0));

        if(not_null($this->icon))
            $this->quotes['icon'] = image($this->icon, $this->title);

        return $this->quotes;
    }

    function check() {
    	if (!isset($this->_check)) {
	        $check = $this->db->db_query("SELECT configuration_value FROM ".TABLE_CONFIGURATION." WHERE configuration_key = 'MODULE_SHIPPING_SELFPICKUP_STATUS'");
	        $this->_check = $check->_numOfRows;
		}
        return $this->_check;
    }

    function install() {
         $this->db->db_query("INSERT INTO ".TABLE_CONFIGURATION." (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_SHIPPING_SELFPICKUP_STATUS', 'True', '6', '7', 'cfg_SELECT_option(array(\'True\', \'False\'), ', now())");
         $this->db->db_query("INSERT INTO ".TABLE_CONFIGURATION." (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_SHIPPING_SELFPICKUP_ALLOWED', '', '6', '0', now())");
         $this->db->db_query("INSERT INTO ".TABLE_CONFIGURATION." (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_SHIPPING_SELFPICKUP_SORT_ORDER', '0', '6', '4', now())");
    }

    function remove() {
         $this->db->db_query("DELETE FROM ".TABLE_CONFIGURATION." WHERE configuration_key IN ('".implode("', '", $this->keys())."')");
    }

    function keys() {
        return array('MODULE_SHIPPING_SELFPICKUP_STATUS',
        			'MODULE_SHIPPING_SELFPICKUP_SORT_ORDER',
        			'MODULE_SHIPPING_SELFPICKUP_ALLOWED');
    }
}
?>